package com.tgz.rocketmq;
/**
 * @author hsj
 * @description:
 * @date 2023/1/5 15:26
 */

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@RocketMQMessageListener(topic = "spring-tx-my-topic",
        consumerGroup = "tx-consumer",//多个消费者时候，保证只有一个消费者消费该topic消息
        selectorExpression = "*")
public class SpringTxConsumer implements RocketMQListener<String> {

    @Override
    public void onMessage(String msg) {
        log.info("【消费者】接收到消息 -> " + msg);
    }
}

